package com.example.demo2;

import android.graphics.drawable.AnimationDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class MainActivity extends AppCompatActivity {
 private ImageView iv_wifi;
    private ImageView iv_zk;
    private ImageView iv_zj;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        iv_wifi = findViewById(R.id.image_wifi);
        iv_wifi.setImageResource(R.drawable.wifi);
        AnimationDrawable animationDrawable1 = (AnimationDrawable) iv_wifi.getDrawable();
        animationDrawable1.start();


        iv_zk =findViewById(R.id.img_zk);
        iv_zj = findViewById(R.id.img_zj);

      /*  Animation animation = AnimationUtils.loadAnimation(MainActivity.this, R.anim.alpha_anim);
        iv_zk.startAnimation(animation);*/
      startRotateAnimation();
      startTranslateAnimation();
    }

    private void startTranslateAnimation() {
        TranslateAnimation translateAnimation = new TranslateAnimation(0,300,0,-500);
        translateAnimation.setDuration(3000);
        translateAnimation.setRepeatCount(300);
        translateAnimation.setFillAfter(false);
        iv_zj.startAnimation(translateAnimation);
    }

    private void startRotateAnimation() {
        RotateAnimation rotateAnimation = new RotateAnimation(0,360,300,400);
        rotateAnimation.setDuration(800);
        rotateAnimation.setRepeatCount(3000);
        iv_zk.startAnimation(rotateAnimation);
    }
}
